home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swagn_r.zip / RECORDS.SWG / 0008_Fast Delete Typed Records.pas < prev    next >
Pascal/Delphi Source File  |  1993-05-31  |  987b  |  37 lines

  1. BG>JB>A method that I have successfully used to delete records in place is
  2. BG>JB>to...
  3.  
  4.   'Scuse me for butting in, but I have another approach which will
  5.   preserve your record order. I will present it for a file of records
  6.   the total size of which is less than 64K. The routine may easily be
  7.   adapted for large files:
  8.  
  9. procedure del_rec(fname : string;target : longint;rec_size : longint);
  10. type
  11.   t_buf=array[1..65520] of byte;
  12.  
  13. var
  14.   f : file;
  15.   buf : t_buf;
  16.   n : word;
  17.  
  18. begin
  19.   new(buf);
  20.   assign(f,fname);  { open your file }
  21.   reset(f,1);
  22.   blockread(f,buf,sizeof(buf),n);
  23.   close(f);
  24.  
  25.   move(bufsucc(target)*rec_size],buftarget*rec_size],n-(target*rec_size));
  26.   dec(n,rec_size);
  27.   rewrite(f,1);
  28.   blockwrite(f,buf,n);
  29.   close(f);
  30.   dispose(buf);
  31. end;
  32. ---
  33.  * The Right Place (tm) BBS/Atlanta - 404/476-2607 SuperRegional Hub
  34.  * PostLink(tm) v1.05  TRP (#564) : RelayNet(tm)
  35. ---
  36.  ■ OLX 2.1 TD ■ I just steal 'em, I don't explain 'em.
  37.